@dnd-prefix-cls: ~'x6-widget-dnd';
@stencil-prefix-cls: ~'x6-widget-stencil';

.@{dnd-prefix-cls} {
  position: absolute;
  top: -10000px;
  left: -10000px;
  z-index: 999999;
  display: none;
  cursor: move;
  opacity: 0.7;
  pointer-events: 'cursor';

  &.dragging {
    display: inline-block;
  }

  &.dragging * {
    pointer-events: none !important;
  }

  .x6-graph {
    background: transparent;
    box-shadow: none;
  }
}

.@{stencil-prefix-cls} {
  position: absolute;
  inset: 0;

  &::after {
    position: absolute;
    top: 0;
    display: block;
    width: 100%;
    height: 20px;
    padding: 8px 0;
    line-height: 20px;
    text-align: center;
    opacity: 0;
    transition: top 0.1s linear, opacity 0.1s linear;
    content: ' ';
    pointer-events: none;
  }

  &-content {
    position: absolute;
    inset: 0;
    height: auto;
    overflow: hidden auto;
  }

  .x6-node [magnet]:not([magnet='passive']) {
    pointer-events: none;
  }

  &-group {
    padding: 0;
    padding-bottom: 8px;
    overflow: hidden;
    user-select: none;

    &.collapsed {
      height: auto;
      padding-bottom: 0;
    }

    &-title {
      position: relative;
      margin-top: 0;
      margin-bottom: 0;
      padding: 4px;
      cursor: pointer;
    }
  }

  &-title,
  &-group > &-group-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    user-select: none;
  }

  .unmatched {
    opacity: 0.3;
  }

  .x6-node.unmatched {
    display: none;
  }

  &-group.unmatched {
    display: none;
  }

  &-search-text {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: 100%;
    height: 30px;
    max-height: 30px;
    line-height: 30px;
    outline: 0;
  }

  &.not-found::after {
    opacity: 1;
    content: attr(data-not-found-text);
  }

  &.not-found.searchable::after {
    top: 30px;
  }

  &.not-found.searchable.collapsable::after {
    top: 50px;
  }
}

// theme
.@{stencil-prefix-cls} {
  color: #333;
  background: #f5f5f5;

  &-content {
    position: absolute;
    top: 32px;
  }

  &.searchable > &-content {
    top: 80px;
  }

  &.not-found::after {
    position: absolute;
  }

  &.not-found.searchable.collapsable::after {
    top: 80px;
  }

  &.not-found.searchable::after {
    top: 60px;
  }

  &-group {
    height: auto;
    margin-bottom: 1px;
    padding: 0;
    transition: none;

    .x6-graph {
      background: transparent;
      box-shadow: none;
    }

    &.collapsed {
      height: auto;
      max-height: 31px;
    }
  }

  &-title,
  &-group > &-group-title {
    position: relative;
    left: 0;
    box-sizing: border-box;
    width: 100%;
    height: 32px;
    padding: 0 5px 0 8px;
    color: #666;
    font-weight: 700;
    font-size: 12px;
    line-height: 32px;
    cursor: default;
    transition: all 0.3;

    &:hover {
      color: #444;
    }
  }

  &-title {
    background: #e9e9e9;
  }

  &-group > &-group-title {
    background: #ededed;
  }

  &.collapsable > &-title,
  &-group.collapsable > &-group-title {
    padding-left: 32px;
    cursor: pointer;

    &::before {
      position: absolute;
      top: 6px;
      left: 8px;
      display: block;
      width: 18px;
      height: 18px;
      margin: 0;
      padding: 0;
      background-color: transparent;
      background-repeat: no-repeat;
      background-position: 0 0;
      border: none;
      content: ' ';
    }
  }

  &.collapsable > &-title::before,
  &-group.collapsable > &-group-title::before {
    background-image: url('');
    opacity: 0.4;
    transition: all 0.3s;
  }

  &.collapsable > &-title:hover::before,
  &-group.collapsable > &-group-title:hover::before {
    opacity: 0.6;
  }

  &.collapsable.collapsed > &-title::before,
  &-group.collapsable.collapsed > &-group-title::before {
    background-image: url('');
    opacity: 0.4;
  }

  &.collapsable.collapsed > &-title:hover::before,
  &-group.collapsable.collapsed > &-group-title:hover::before {
    opacity: 0.6;
  }

  input[type='search'] {
    appearance: textfield;
  }

  input[type='search']::-webkit-search-cancel-button,
  input[type='search']::-webkit-search-decoration {
    appearance: none;
  }

  &-search-text {
    display: block;
    width: 90%;
    margin: 8px 5%;
    padding-left: 8px;
    color: #333;
    background: #fff;
    border: 1px solid #e9e9e9;
    border-radius: 12px;
    outline: 0;

    &:focus {
      outline: 0;
    }
  }

  &::after {
    color: #808080;
    font-weight: 600;
    font-size: 12px;
    background: 0 0;
  }

  .x6-node.x6-node-immovable {
    cursor: move;
  }
}
